package com.example.datapass;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {
    private EditText str1;
    private EditText str2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.i("Aty1" ,"执行onCreate");
        Button btn=(Button) findViewById(R.id.btnGo);
        str1=(EditText)findViewById(R.id.editText3);
        str2 =(EditText)findViewById(R.id.editText4);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String str = null;
                switch (view.getId()) {
                    case R.id.btnGo:
                        int i1 = Integer.parseInt(String.valueOf(str1.getText()));
                        int i2 = Integer.parseInt(String.valueOf(str2.getText()));
                        int sum = i1 + i2;
                        str = Integer.toString(sum);
                        Intent intent = new Intent(MainActivity.this, SecondActivity.class);
                        intent.putExtra("sum", str);
                        startActivity(intent);
                }
            }
        });
    }
    @Override
    protected void onStart() {
        super.onStart();
        Log.i("Aty1" ,"执行onStart");
    }
    @Override
    protected void onRestart() {
        super.onRestart();
        Log.i("Aty1" ,"执行onRestart");
    }
    @Override
    protected void onResume() {
        super.onResume();
        Log.i("Aty1" ,"执行onResume");
    }
    @Override
    protected void onPause() {
        super.onPause();
        Log.i("Aty1" ,"onPause");
    }
    @Override
    protected void onStop() {
        super.onStop();
        Log.i("Aty1" ,"执行onStop");
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.i("Aty1" ,"执行onDestroy");
    }

}